package com.milhouz.bomberrokon.sprite;

import com.stickycoding.Rokon.Sprite;
import com.stickycoding.Rokon.Texture;

/**
 * A solid object is used to defined the coordonate and width of an object that is used in the collision detector. SolidWidth, SolidHeight can be
 * different than the textures Width and Height
 * 
 * @author bpetetot
 * 
 */
public class SolidObject extends Sprite {

	/** direction : STATIC=0, UP=1, DOWN=2, LEFT=3, RIGHT=4 */
	public int mSolidDirection = 0;
	private int mSolidWidth;
	private int mSolidHeight;

	/**
	 * The solid object width and height corresponds to the texture width and height
	 * 
	 * @param x
	 *            Solid X (left) coordonate
	 * @param y
	 *            Solid Y (top) coordonatre
	 * @param texture
	 *            Texture
	 */
	public SolidObject(float x, float y, Texture texture) {
		super(x, y, texture);
		mSolidWidth = (int) getWidth();
		mSolidHeight = (int) getHeight();
	}

	/**
	 * The solid object width and height corresponds to the defined solid width and solid height (not the texture)
	 * 
	 * @param centerX
	 *            Center X coordonate
	 * @param centerY
	 *            Center Y coordonate
	 * @param solidWidth
	 *            Solid Width coordonate
	 * @param solidHeight
	 *            Solid Height coordonate
	 * @param texture
	 *            Texture
	 */
	public SolidObject(float centerX, float centerY, int solidWidth, int solidHeight, Texture texture) {
		super(centerX - (solidWidth / 2), centerY - (solidHeight / 2), solidWidth, solidHeight, texture);
		mSolidWidth = solidWidth;
		mSolidHeight = solidHeight;
	}

	/** Get the X (left) coordonate of the solid (used for collision detection) */
	public float getSolidX() {
		return this.getX() + ((this.getWidth() - mSolidWidth) / 2);
	}

	/** Get the Y (top) coordonate of the solid (used for collision detection) */
	public float getSolidY() {
		return this.getY() + (this.getHeight() - mSolidHeight);
	}

	/** Get the X center coordonate of the solid (used for collision detection) */
	public float getCenterX() {
		return this.getX() + (this.getWidth() / 2);
	}

	/** Get the Y center coordonate of the solid (used for collision detection) */
	public float getCenterY() {
		return this.getY() + (this.getHeight() / 2);
	}

	/** Set the X center coordonate of the solid (used for collision detection) */
	public void setCenterX(int centerX) {
		setSolidX(centerX - (this.getWidth() / 2));
	}

	/** Set the Y center coordonate of the solid (used for collision detection) */
	public void setCenterY(int centerY) {
		setSolidY(centerY - (this.getHeight() / 2));
	}

	/** Set the X (top) coordonate of the solid (used for collision detection) */
	public void setSolidX(float x) {
		this.setX(x - ((this.getWidth() - mSolidWidth) / 2));
	}

	/** Set the Y (left) coordonate of the solid (used for collision detection) */
	public void setSolidY(float y) {
		this.setY(y - (this.getHeight() - mSolidHeight));
	}

	/** Get the solid width (it's not necessary the texture width) */
	public int getSolidWidth() {
		return mSolidWidth;
	}

	/** Set the solid height (it's not necessary the texture height) */
	public int getSolidHeight() {
		return mSolidHeight;
	}

	@Override
	public float getHeight() {
		// TODO Auto-generated method stub
		return super.getHeight();
	}

	@Override
	public void setHeight(float height) {
		// TODO Auto-generated method stub
		super.setHeight(height);
	}

	@Override
	public float getY() {
		// TODO Auto-generated method stub
		return super.getY();
	}

	@Override
	public void setY(float y) {
		// TODO Auto-generated method stub
		super.setY(y);
	}

}
